﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using nwrole.toolbox.sync.entity;
using System.ServiceModel;

namespace nwrole.toolbox.sync.contract
{
    [Flags]
    public enum DeployStatus : long
    {
        NotInstalled = (long)0,

        SettingsTable = (long)1,
        InstanceTable = (long)2,
        EntityTable = (long)4,
        EntityColumnTable = (long)8
    }

    [ServiceContract]
    public interface ISyncSourceService
    {
        /*[OperationContract]
        String SyncAllSyncEntities();*/

        [OperationContract]
        bool StartFullSync(int instanceId);

        [OperationContract]
        bool SyncNextEntity(int instanceId);

        [OperationContract]
        String SyncSyncEntity(long id);

        [OperationContract]
        String DeploySource(long id);

        [OperationContract]
        String DeleteSyncEntity(long id);

        [OperationContract]
        bool DeploySourceEnvironment();

        [OperationContract]
        SyncEntity ImportSchema(int syncInstanceId, long schemaId, short type);

        [OperationContract]
        SyncEntity GetSchemaEntity(long id, short type);

        [OperationContract]
        bool ToggleSyncEnabled(long id);

        [OperationContract]
        SyncModeEnum ToggleSyncMode(long id);

        [OperationContract]
        bool ToggleSyncColumnEnabled(long id);
        
        [OperationContract]
        void ToggleAllSyncColumnEnabled(long syncEntityId);

        [OperationContract]
        void Update(SyncEntity entity);

        [OperationContract]
        List<SyncEntity> GetSchemaEntities(int page = 0, int pagesize = 1500);

        [OperationContract]
        List<SyncEntity> GetEntities(int syncInstanceId);

        /*[OperationContract]
        SyncEntity GetEntityByName(string name);*/

        [OperationContract]
        SyncEntity GetEntityById(long id);

        [OperationContract]
        DeployStatus GetDeployStatus();

        [OperationContract]
        string GetSettingStringValue(string key);

        [OperationContract]
        void SetSettingValue(string key, string value);
    }

    public interface ISyncSourceServiceChannel : ISyncSourceService, IClientChannel { }
}
